﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Tzeentch
{
    public partial class GUI : Form
    {
        #region Properties
        /// <summary>
        /// Gets or sets the Original Image.
        /// </summary>
        /// <value>
        /// The Original Image.
        /// </value>
        public Bitmap OriginalImage { get; set; }

        /// <summary>
        /// Gets or sets the generated image.
        /// </summary>
        /// <value>
        /// The generated image.
        /// </value>
        public Bitmap GeneratedImage { get; set; }
        #endregion

        public GUI()
        {
            InitializeComponent();
        }

        #region Methods
        /// <summary>
        /// Initialises this instance.
        /// </summary>
        public void Initialise()
        {
                this.Show();            
        }

        /// <summary>
        /// Refreshes the GUI.
        /// </summary>
        public void RefreshGUI()
        {
            pictureBoxGeneratedImage.Image = GeneratedImage.Clone() as Bitmap;
        }
        #endregion

        #region GUIEvents
        private void imageLoaderButton_Click(object sender, EventArgs e)
        {
            openFileDialogLoadImage.ShowDialog();            
        }

        private void openFileDialogLoadImage_FileOk(object sender, CancelEventArgs e)
        {
            OriginalImage = new Bitmap(openFileDialogLoadImage.FileName);
            pictureBox1.Image = OriginalImage.Clone() as Bitmap;
            textBox1.Text = openFileDialogLoadImage.FileName;

            startStopButton.Enabled = true;
        }        
        #endregion

        private void startStopButton_Click(object sender, EventArgs e)
        {
            if (startStopButton.Text == "Start")
            {
                startStopButton.Text = "Stop";
                labelStatus.Text = "Starting";
                labelStatus.ForeColor = Color.Orange;
                buttonPause.Enabled = true;
                groupBoxSettings.Enabled = false;
            }
            else
            {
                startStopButton.Text = "Start";
                labelStatus.Text = "Stopping";
                labelStatus.ForeColor = Color.Orange;
                buttonPause.Enabled = false;
            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxInfinity.Checked)
                numericUpDownNumberOfIterations.Enabled = false;
            else
                numericUpDownNumberOfIterations.Enabled = true;
        }
    }
}
